package me.tuyou.stream;

import me.tuyou.common.MyLog;
import me.tuyou.common.MyLogGenerator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;

public class StreamSinkTest {

    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.addSource(new MyLogGenerator()).writeAsText("file:///Users/tuyou/Downloads/txt.txt");
//        env.addSource(new MyLogGenerator()).writeAsCsv("file:///Users/tuyou/Downloads/csv.txt");
//        env.addSource(new MyLogGenerator()).writeToSocket("localhost", 9999));
//        env.addSource(new MyLogGenerator()).addSink(new SinkFunction<MyLog>() {
//            @Override
//            public void invoke(MyLog value, Context context) throws Exception {
//                System.out.println(value);
//            }
//        });
        env.execute();
    }
}
